let str:string="AB"
let result=convert(str,1)
console.log(result)


function convert(s: string, numRows: number): string {
    var result : string=""
    var arr:string[]=new Array(numRows).fill("")
    var flag=0;//0往下 1往上
    var col=0;
    for (let i = 0; i < s.length; i++) {
        arr[col]+=s[i]
        if(numRows===1)
            continue;
        if(flag===0){ //往下走
            col++;
        }else {//往上走
            col--;
        }
        if (col===numRows-1||col===0){
         flag= flag===0 ?1:0;  // 1转0 0转1
        }
    }
    for (let i = 0; i < arr.length; i++) {
        result+=arr[i]
    }
    return result;
};